package com.hjwoo.app.ui;


import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.widget.ImageView;

import com.hjwoo.app.R;

public class ProgressDialogHelper
{
    public static Dialog               progressDialog       = null;
    public static ProgressDialogHelper progressDialogHelper = null;
    private ImageView         dialogimg;
    private AnimationDrawable animationDrawable;

    public static ProgressDialogHelper getProgressDialogHelper()
    {
        if (progressDialogHelper == null)
        {
            progressDialogHelper = new ProgressDialogHelper();
        }
        return progressDialogHelper;
    }

    public void dismissDialog()
    {
        if (progressDialog != null)
        {
            progressDialog.dismiss();
            progressDialog = null;
        }
    }

    public void creatProgress(Context context)
    {
        if (progressDialog != null)
        {
            return;
        }
        progressDialog = new Dialog(context, R.style.loading_dialog);
        progressDialog.setContentView(R.layout.net_waitbox);

//        WindowManager.LayoutParams  wp = progressDialog.getWindow().getAttributes();
//        wp.alpha = 10f;

        dialogimg = (ImageView) progressDialog.findViewById(R.id.dialog_image);
        dialogimg.setImageResource(R.drawable.progress_anidialog);
        animationDrawable = (AnimationDrawable) dialogimg.getDrawable();
        animationDrawable.start();
//        progressDialog.setCancelable(true);
//        progressDialog.setCanceledOnTouchOutside(false);
//        progressDialog.setDismissMessage();

//        WindowManager windowManager = progressDialog.getWindow().getWindowManager();
//        Display display = windowManager.getDefaultDisplay();
//        WindowManager.LayoutParams lp = progressDialog.getWindow().getAttributes();
//        lp.width = (int) (display.getWidth()); //设置宽度
//        progressDialog.getWindow().setAttributes(lp);

        progressDialog.show();

//        progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
//            @Override
//            public void onCancel(DialogInterface dialogInterface) {
//                HttpTool.cancelable.cancel();
//                LoanLog.e("请求中断", "请求中断1");
//            }
//        });
    }


}
